Crate home

source ·
Expand description

Canonical definitions of home_dir, cargo_home, and rustup_home.

The definition of home_dir provided by the standard library is incorrect because it considers the HOME environment variable on Windows. This causes surprising situations where a Rust program will behave differently depending on whether it is run under a Unix emulation environment like Cygwin or MinGW. Neither Cargo nor rustup use the standard libraries definition - they use the definition here.

This crate provides two additional functions, cargo_home and rustup_home, which are the canonical way to determine the location that Cargo and rustup use to store their data. The env module contains utilities for mocking the process environment by Cargo and rustup.

See also this discussion.

Modules

  • Lower-level utilities for mocking the process environment.

Functions

  • Returns the storage directory used by Cargo, often knowns as .cargo or CARGO_HOME.
  • Returns the storage directory used by Cargo within cwd. For more details, see cargo_home.
  • Returns the path of the current user’s home directory using environment variables or OS-specific APIs.
  • Returns the storage directory used by rustup, often knowns as .rustup or RUSTUP_HOME.
  • Returns the storage directory used by rustup within cwd. For more details, see rustup_home.